package com.monboo.album.view.component
{
	
	import flash.display.Sprite;
	import com.monboo.album.common.AlbumConst;
	import com.monboo.utils.GetStage;
	import com.monboo.utils.FullState;
	import com.monboo.album.view.AlbumInfoMediator;
	
	public class MousePlane extends AbstractChangeUI
	{
		private var imageInfo:AlbumInfoMediator;
		
		public function MousePlane(_imageInfo:AlbumInfoMediator)
		{
			super(_imageInfo);
			imageInfo = _imageInfo;
			
			toWidth = AlbumConst.imageWidth;
			toHeight = AlbumConst.imageHeight;
		}
		override public function changeSize(pic:Sprite,degrees:Number=0):void {	
			w = imageInfo.imageWidth;
			h = imageInfo.imageHeight;
			
			if(FullState.fullState){		
				toWidth = GetStage.theStage().stageWidth;
				toHeight = GetStage.theStage().stageHeight;
				
				pic.parent.width = toWidth;
				pic.parent.height = toHeight;
				setPosition(pic,toWidth,toHeight);	
			}else{				
				toWidth = imageInfo.imageWidth;
				toHeight = imageInfo.imageHeight;
				setSize(pic,toWidth,toHeight,w,h);
				setPosition(pic,toWidth, toHeight);
			}		
		}
		override protected function setSize(pic:Sprite,bigPicWidth:Number,bigPicHeight:Number,w:Number,h:Number):void{
			pic.parent.scaleX = pic.parent.scaleY = 1;
			if(w/h > bigPicWidth/bigPicHeight){
				pic.parent.scaleX = pic.parent.scaleY = bigPicWidth/w;
			}else if(w/h < bigPicWidth/bigPicHeight){
				pic.parent.scaleX = pic.parent.scaleY = bigPicHeight/h;
			}else if(w/h == bigPicWidth/bigPicHeight){
				pic.parent.scaleX = pic.parent.scaleY = bigPicWidth/w;
			}
			
		}	
		override protected function setPosition(pic:Sprite,w:Number,h:Number,degrees:Number=0):void{
			if(FullState.fullState){
				top=0;
				left=0;
			}else{
				top=imageInfo.imageY;
				left=imageInfo.imageX;
			}
			
			pic.parent.x = (w - pic.parent.width)/2 + left;
			pic.parent.y = (h - pic.parent.height)/2 + top;
		}
	}
}